﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <title>Find maximal sequence</title>
     <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
	    var arr = [4, 23, 4, 4, 2, 1, 1, 1, 1, 5, 8, 5];
	    var max = 1;
	    var count = 1;
	    var element = 1;
        var temp = arr[0];
        for (var i = 1; i < arr.length; i++){
            if (temp == arr[i]){
                count++;
                if (count > max){
                    max = count;
                    element = temp;
	            }
	        }
	        else{
                count = 1;
                temp = arr[i];
	        }
	    }
        jsConsole.writeLine("The maximal sequence of equal elements is: " + max
            + " -> " );
        for (var i = 0; i < max; i++)
	    {
            jsConsole.write(element + " ");
	    }
    </script>
</body>
</html>
